package com.hitechbangla.fctu.utility.enumall;

/**
 *
 * @author deb kanti
 */

    public enum CommandType 
    {

        Type1, Type2, Type3, Type4, Type5, Type6, Type7, // these are all turn commands
        Type8, 
        Type9; // this is heigth change command
        
        private String turn_left = "l";
        private String turn_right = "r";
        private String make_heading_command = "heading";
        private String degrees_command = "d";
        private String roll_out = "r";
        private String continue_current = "c";
        
        // turning angle
        private String slack = "s";
        private String normal = "n";
        private String tight = "t";
        private String orbit_command = "o";
        
        //for speed change
        private String make_speed = "makespeed";
        private String accelarate = "accelerate";
        private String decelarate = "decelarate";
        
        // this is a identifier for the aircraft
        private String call_sign = "[0-9]{3}";
        
        public String heading_angle = "[0-9]{1,3}";
        public String slack_tight_normal = "[" + slack + normal + tight + "]?";
        public String left_right = "[" + turn_right + turn_left + "]";
        public String given_speed = "[0-9]{1,4}";
        
        // for height change
        
        public String height_change_tag = "h";
        public String expedite= "[0-9]{0,2}";
        public String height_change_type="[cdm]";
        public String height_change = "[0-9]+";
        
        public String speed_change="s";
        public String speed_change_volume="[0-9]+";
        

        // this array contains the regular expressions for the turn commands
        String[] turn_command = 
        {
            call_sign + "(" + slack_tight_normal + ")" + "(" + left_right + ")" + "(" + heading_angle + ")",
            call_sign + "(" + slack_tight_normal + ")" + "(" + left_right + ")" + "(" + heading_angle + ")" + degrees_command,
            call_sign + "(" + slack_tight_normal + ")" + make_heading_command + "(" + heading_angle + ")",
            call_sign + roll_out,
            call_sign + "(" + slack_tight_normal + ")" + continue_current + "(" + heading_angle + ")",
            call_sign + "(" + slack_tight_normal + ")" + orbit_command + "(" + left_right + ")",
	    call_sign + "(" + slack_tight_normal + ")" + "(" + left_right + ")", // this is the curtailed command last added
            call_sign + height_change_tag  + "(" +  expedite + ")" + "(" + height_change_type + ")" + "(" + height_change + ")",
            call_sign + "(" + speed_change + ")"  + "(" + speed_change_volume + ")"
        };

        CommandType() 
        {
            
        } // end of constructor function

        public String getRegEx() 
        {
            switch (this) 
            {
                case Type1:
                    return turn_command[0];
                case Type2:
                    return turn_command[1];
                case Type3:
                    return turn_command[2];
                case Type4:
                    return turn_command[3];
                case Type5:
                    return turn_command[4];
                case Type6:
                    return turn_command[5];
                case Type7:
                    return turn_command[6];
		case Type8:
		    return turn_command[7];
                case Type9:
		    return turn_command[8];
                default:
                    return null;
            }
        }  // end of getRegEx function
        
        
        public TurnDirection getDirectionFromRegEx(String direction)  // value of direction is l or r, as in regular expresssion commands
        {
            if(direction.equals("l") )
            {
                return TurnDirection.LEFT;
            }
            else
            {
                return TurnDirection.RIGHT;
            }
        } // end of getDirectionFromRegEx function
        
        public TurnDegree getDegreeFromRegEx(String direction)  // value of degree is s, t or n, as in regular expresssion commands
        {
            if(direction.equals("s" ))
            {
                return TurnDegree.SLACK;
            }
            
            else if(direction.equals("t" ))
            {
                return TurnDegree.TIGHT;
            }            
            else
            {
                return TurnDegree.NORMAL;
            }
        } // // end of // end of getDirectionFromRegEx function

	public AircraftHeightChangeType getHeightChangeTypeFromRegEx(String heightChangeType)
        {
            if(height_change.equals("c"))
            {
                return AircraftHeightChangeType.CLIMB;
            }
            else if(height_change.equals("d"))
            {
                return AircraftHeightChangeType.DESCEND;
            }
            else
            {
                return AircraftHeightChangeType.MAKE;
            }
        }
}


